{{include template('public/header','admin')}}
</head>
<body>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <div class="page-header">
                    <h3>{{$action}}[{{$modelname}}]字段</h3>
                </div>
                <form action="{{url($postUrl)}}" method="post" class="form-horizontal validform" id="cpform" name="cpform" role="form" autocomplete='off' >
                    <input type="hidden" name="formhash" value="{{FORMHASH}}" />
                    <input type="hidden" id="formscrolltop" name="scrolltop" value="" />
                    <input type="hidden" name="anchor" value="luomingui" />
                    <input type='hidden' name='fieldid' value="{{$item.fieldid}}" />
                    <input type='hidden' name='modelid' value="{{$item.modelid}}" />
                    <input type='hidden' name='action' value="{{$action}}" />
                    <input type="hidden" name="fieldtype" value="{{$item.fieldtype}}">
                    <table class="table table-border ticky_table">
                        <tr>
                            <td class="w_100"> <span class="red">*</span>{{L('modelfield_fieldtype')}}：</td>
                            <td>
                                <select name="fieldtype" id="fieldtype" class="form-control" datatype="*"  onchange="javascript:field_setting(this.value);" {{if $action eq '修改'}}disabled="disabled"{{/if}}>
                                        <option value='0'>请选择字段类型</option>
                                    <option value="input" {{if $item.fieldtype eq 'input'}}selected{{/if}}>单行文本</option>
                                    <option value="textarea" {{if $item.fieldtype eq 'textarea'}}selected{{/if}}>多行文本</option>
                                    <option value="number" {{if $item.fieldtype eq 'number'}}selected{{/if}}>整数类型</option>
                                    <option value="datetime" {{if $item.fieldtype eq 'datetime'}}selected{{/if}}>时间类型</option>
                                    <option value="image" {{if $item.fieldtype eq 'image'}}selected{{/if}}>图片上传</option>
                                    <option value="images" {{if $item.fieldtype eq 'images'}}selected{{/if}}>多图片上传</option>
                                    <option value="attachment" {{if $item.fieldtype eq 'attachment'}}selected{{/if}}>附件上传</option>
                                    <option value="select" {{if $item.fieldtype eq 'select'}}selected{{/if}}>option下拉框</option>
                                    <option value="radio"{{if $item.fieldtype eq 'radio'}}selected{{/if}}>radio选项卡</option>
                                    <option value="checkbox" {{if $item.fieldtype eq 'checkbox'}}selected{{/if}}>checkbox多选框</option>
                                    <option value="editor" {{if $item.fieldtype eq 'editor'}}selected{{/if}}>编辑器</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100"> <span class="red">*</span>{{L('modelfield_name')}}：</td>
                            <td><input type="text" id="name" name='name' value="{{$item.name}}"  class='form-control' tabindex="5" {{if $action eq '添加'}}onblur="tickycms_pinyin()"{{/if}} datatype="*" nullmsg="请输入{{L('modelfield_name')}}！" errormsg="{{L('modelfield_name')}}错误,请重新输入！" placeholder="请输入{{L('modelfield_name')}}" />
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100"> <span class="red">*</span>{{L('modelfield_field')}}：</td>
                            <td><input type="text" id="field" name='field' value="{{$item.field}}"  class='form-control' tabindex="3"  datatype="*" nullmsg="请输入{{L('modelfield_field')}}！" errormsg="{{L('modelfield_field')}}错误,请重新输入！" placeholder="请输入{{L('modelfield_field')}}" />
                            </td>
                        </tr>
                        <tr {{if !in_array($item['fieldtype'], array('select','radio','checkbox')) }}  style="display:none"{{/if}} id="options">
                            <td>选项列表</td>
                            <td><textarea style="height:100px;" name="setting" id="textarea" class="form-control">
         {{if in_array($item['fieldtype'], array('select','radio','checkbox')) && $item['setting'] }} {{join('|',string2array($item['setting']))}}{{/if}}
                                </textarea>
                                <span class="tip">用“|”分开，如“男|女|人妖”</span></td>
                        </tr>
                        <tr>
                            <td class="w_100"> <span class="red">*</span>{{L('modelfield_datatype')}}：</td>
                            <td>
                                <select name="datatype" id="datatype" class="form-control">
                                    <option value='0'>请选择字段类型</option>
                                    <option value="*" {{if $item.datatype eq '*'}}selected{{/if}}>不为空</option>
                                    <option value="date" {{if $item.datatype eq 'date'}}selected{{/if}}>时间类型</option>
                                    <option value="zh" {{if $item.datatype eq 'zh'}}selected{{/if}}>中文</option>
                                    <option value="money" {{if $item.datatype eq 'money'}}selected{{/if}}>货币类型</option>
                                    <option value="ipv4" {{if $item.datatype eq 'ipv4'}}selected{{/if}}>ip地址</option>
                                    <option value="num" {{if $item.datatype eq 'num'}}selected{{/if}}>数值</option>
                                    <option value="qq" {{if $item.datatype eq 'qq'}}selected{{/if}}>QQ号码</option>
                                    <option value="idcard"{{if $item.datatype eq 'idcard'}}selected{{/if}}>身份证号码</option>
                                    <option value="username" {{if $item.datatype eq 'username'}}selected{{/if}}>请填写4至16位，以字母开头，字母，数字，减号，下划线</option>
                                    <option value="password" {{if $item.datatype eq 'password'}}selected{{/if}}>请填写4到16位 字母和数字</option>
                                    <option value="bus" {{if $item.datatype eq 'bus'}}selected{{/if}}>车牌号</option>
                                    <option value="color" {{if $item.datatype eq 'color'}}selected{{/if}}>十六进制颜色</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100"> <span class="red">*</span>{{L('modelfield_nullmsg')}}：</td>
                            <td><input type="text" id="nullmsg" name='nullmsg' value="{{$item.nullmsg}}"  class='form-control' tabindex="7"datatype="*" nullmsg="请输入{{L('modelfield_nullmsg')}}！" errormsg="{{L('modelfield_nullmsg')}}错误,请重新输入！" placeholder="请输入{{L('modelfield_nullmsg')}}" />
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100"> <span class="red">*</span>{{L('modelfield_errormsg')}}：</td>
                            <td><input type="text" id="errormsg" name='errormsg' value="{{$item.errormsg}}"  class='form-control' tabindex="8" 	datatype="*" nullmsg="请输入{{L('modelfield_errormsg')}}！" errormsg="{{L('modelfield_errormsg')}}错误,请重新输入！" placeholder="请输入{{L('modelfield_errormsg')}}" />
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100"> <span class="red">*</span>{{L('modelfield_placeholder')}}：</td>
                            <td><input type="text" id="placeholder" name='placeholder' value="{{$item.placeholder}}"  class='form-control' tabindex="9" datatype="*" nullmsg="请输入{{L('modelfield_placeholder')}}！" errormsg="{{L('modelfield_placeholder')}}错误,请重新输入！" placeholder="请输入{{L('modelfield_placeholder')}}" />
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100">{{L('modelfield_ajaxurl')}}：</td>
                            <td><input type="text" id="ajaxurl" name='ajaxurl' value="{{$item.ajaxurl}}"  class='form-control' tabindex="10"  placeholder="请输入{{L('modelfield_ajaxurl')}}" />
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100">{{L('modelfield_css')}}：</td>
                            <td><input type="text" id="css" name='css' value="{{$item.css}}"  class='form-control' tabindex="11" placeholder="请输入{{L('modelfield_css')}}" />
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100">{{L('modelfield_defaultvalue')}}：</td>
                            <td><input type="text" id="defaultvalue" name='defaultvalue' value="{{$item.defaultvalue}}"  class='form-control' tabindex="12"  placeholder="请输入{{L('modelfield_defaultvalue')}}" />
                            </td>
                        </tr>
                        <tr><td></td><td><input type="submit" name="dosubmit" class="btn btn-primary" value="{{L('submit')}}" style="width: 54px;" /></td></tr>
                    </table>
                    <script type="text/javascript">
                        $(function () {
                            $(".validform").Validform({tiptype: 3, showAllError: true, ajaxPost: true,
                                callback: function (ret) {
                                    if (ret.status == "y") {
                                        location.href = "/admin/model_field/?modelid={{ticky\request::get('modelid', 0)}}";
                                    } else {
                                        layer.msg(ret.info);
                                    }
                                }
                            });
                        });
                    </script>
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="{{STATIC_URL}}/plugins/pinyin.js"></script>
    <script type="text/javascript">
                        function tickycms_pinyin() {
                            var name = trim($("input[name='name']").val());
                            var pinyin = codefans_net_CC2PY(name);
                            $("input[name='field']").val(pinyin.toLowerCase());
                            $("input[name='placeholder']").val('请输入' + name);
                            $("input[name='nullmsg']").val('请输入' + name);
                            $("input[name='errormsg']").val(name + '输入错误');
                        }
                        function field_setting(fieldtype) {
                            if (fieldtype == 'select' || fieldtype == 'radio' || fieldtype == 'checkbox') {
                                $('#options').css('display', '');
                            } else {
                                $('#options').css('display', 'none');
                            }
                            if (fieldtype == 'datetime') {
                                $('#dates').css('display', '');
                            } else {
                                $('#dates').css('display', 'none');
                            }
                        }
    </script>
</body>
</html>